package com.wct.spzx.common.exception;

import com.wct.spzx.model.vo.common.Result;
import com.wct.spzx.model.vo.common.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Administrator
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    /** 全局异常处理
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result<Void> error(Exception e) {
        log.error("系统异常", e);;
        return Result.build(null, ResultCodeEnum.SYSTEM_ERROR);
    }

    @ExceptionHandler(LoginErrorException.class)
    @ResponseBody
    public Result<Void> error(LoginErrorException e) {
        return Result.build(null, e.getResultCodeEnum());
    }
}
